/*

 */
package com.ohos.connent.bizscenecloud.dev.modular.file.provider;

import com.ohos.connent.bizscenecloud.dev.api.DevFileApi;
import com.ohos.connent.bizscenecloud.dev.modular.file.enums.DevFileEngineTypeEnum;
import com.ohos.connent.bizscenecloud.dev.modular.file.service.DevFileService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 文件API接口提供者
 *
 *
 **/
@Service
public class DevFileApiProvider implements DevFileApi {

    @Resource
    private DevFileService devFileService;

    @Override
    public String storageFileWithReturnUrlLocal(MultipartFile file) {
        return devFileService.uploadReturnUrl(DevFileEngineTypeEnum.LOCAL.getValue(), file);
    }

    @Override
    public String storageFileWithReturnIdLocal(MultipartFile file) {
        return devFileService.uploadReturnId(DevFileEngineTypeEnum.LOCAL.getValue(), file);
    }

    @Override
    public String storageFileWithReturnUrlAliyun(MultipartFile file) {
        return devFileService.uploadReturnUrl(DevFileEngineTypeEnum.ALIYUN.getValue(), file);
    }

    @Override
    public String storageFileWithReturnIdAliyun(MultipartFile file) {
        return devFileService.uploadReturnId(DevFileEngineTypeEnum.ALIYUN.getValue(), file);
    }

    @Override
    public String storageFileWithReturnUrlTencent(MultipartFile file) {
        return devFileService.uploadReturnUrl(DevFileEngineTypeEnum.TENCENT.getValue(), file);
    }

    @Override
    public String storageFileWithReturnIdTencent(MultipartFile file) {
        return devFileService.uploadReturnId(DevFileEngineTypeEnum.TENCENT.getValue(), file);
    }

    @Override
    public String storageFileWithReturnUrlMinio(MultipartFile file) {
        return devFileService.uploadReturnUrl(DevFileEngineTypeEnum.MINIO.getValue(), file);
    }

    @Override
    public String storageFileWithReturnIdMinio(MultipartFile file) {
        return devFileService.uploadReturnId(DevFileEngineTypeEnum.MINIO.getValue(), file);
    }

    /**
     * 上传文件返回Url
     *
     * @param file 文件
     **/
   public  String storageFileWithReturnUrlHUAWEI(MultipartFile file){
        return devFileService.uploadReturnUrl(DevFileEngineTypeEnum.HUAWEI.getValue(), file);
    }

    /**
     * 上传文件返回Id
     *
     * @param file 文件
     **/
    public String storageFileWithReturnIdHUAWEI(MultipartFile file){
        return devFileService.uploadReturnId(DevFileEngineTypeEnum.HUAWEI.getValue(), file);
    }

    /**
     * 获取下载文件的授权URL
     *
     * @param id 文件ID
     * @param timeoutSeconds 超时时间默认 3600秒
     **/
    public String getFileDownloadAuthUrlHUAWEI(String id, Long timeoutSeconds){
        return devFileService.getFileDownloadAuthUrl(DevFileEngineTypeEnum.HUAWEI.getValue(),id,timeoutSeconds);
    }

    public String getFileUploadAuthUrlHUAWEI(String fileName, Long timeoutSeconds){
        return devFileService.getFileUploadAuthUrlHUAWEI(DevFileEngineTypeEnum.HUAWEI.getValue(),fileName,timeoutSeconds);
    }

    public boolean isExistingFileHUAWEI(String id) {
        return devFileService.isExistingFile(DevFileEngineTypeEnum.HUAWEI.getValue(), id);
    }

    public void storageFileHUAWEI(String id, MultipartFile file) {
        devFileService.storageFile(DevFileEngineTypeEnum.HUAWEI.getValue(), id, file);
    }
}
